package com.app.studentActivity.fragment;

import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.app.R;
import com.app.studentActivity.Kuaidi;
import com.app.studentActivity.LiaoTian;
import com.app.studentActivity.Qingjia;
import com.app.studentActivity.Qiye;
import com.app.studentActivity.Shiwu;
import com.app.studentActivity.Tushu;

public class StudentFragment extends Fragment {

    private TextView text1, text2, text3, text4, text5;
    private int id;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_student, container, false);
        initView(view);
        id = getActivity().getIntent().getIntExtra("id", 0);
        text1.setOnClickListener(v -> startActivity(new Intent(getContext(), Tushu.class)));
        text2.setOnClickListener(v -> startActivity(new Intent(getContext(), Kuaidi.class)));
        text3.setOnClickListener(v -> {
            Intent intent = new Intent(getContext(), LiaoTian.class);
            intent.putExtra("id", id);
            startActivity(intent);
        });
        text4.setOnClickListener(v -> startActivity(new Intent(getContext(), Qiye.class)));
        text5.setOnClickListener(v -> startActivity(new Intent(getContext(), Shiwu.class)));
        return view;
    }

    private void initView(View view) {
        Toolbar toolbar = view.findViewById(R.id.toolbar);
        toolbar.getChildAt(0).setVisibility(View.GONE);
        ((TextView) toolbar.getChildAt(1)).setText("生活模块");
        text1 = view.findViewById(R.id.text1);
        text2 = view.findViewById(R.id.text2);
        text3 = view.findViewById(R.id.text3);
        text4 = view.findViewById(R.id.text4);
        text5 = view.findViewById(R.id.text5);
    }
}